	<?php $this->load->view('admin/partials/general_menu'); ?>
	<?php 
		$ci= &get_instance();	
		$recordArray = $ci->auction_coupon->getList();
	?>
	
	<div class="clrboth"></div>
	<h3>Auction Coins Packages</h3>
	<?php $buttons = array('buttons'=>array('Add#add_coin_auction();') );?>
	<?php $this->load->view('admin/partials/buttons', $buttons ); ?>

	<div class="clrboth"></div>
	
	<table border="0" class="table-list">
		<thead>
			<tr>
				<th>Credits From</th>
				<th>Credits To</th>
				<th>Coins</th>
				<th>Days Accept</th>
				<th><?php echo lang('dataman.manage'); ?></th>
			</tr>
		</thead>
		
		<tbody>
			<?php foreach( $recordArray as $item ): ?>
			<?php 
				$PACKAGE = $ci->auction_coupon->init('id', $item->id); 
			?>
			<tr>
				<td><?php echo $PACKAGE->getFrom(); ?></td>
				<td><?php echo $PACKAGE->getTo(); ?></td>
				<td><?php echo $PACKAGE->getCoins(); ?></td>
				<td><?php echo $PACKAGE->getDaysAccept(); ?></td>
				<td>
					<a href="javascript:void(0);" onclick="auction_cp_edit(<?php echo $PACKAGE->getId();?>)"><?php echo lang('dataman.edit');?></a>
						&nbsp;|&nbsp;
					<a href="javascript:void(0);" onclick="auction_cp_delete(<?php echo $PACKAGE->getId();?>)" ><?php echo lang('dataman.delete');?></a>
				</td>
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>

<script type="text/javascript">
	jQuery(document).ready(function(){
		var optionsAuction = { 
			beforeSubmit:function(formData, jqForm, options){ 
							return true;
						},   
			success:function(responseText, statusText, xhr, $form){
				if(responseText == 'ok'){
					reload();
				}else{
					alert(responseText);
				}
			}   
		};	
		jQuery("#auction_coin_submit").live("submit",function(e){
			e.preventDefault(); // <-- important
			jQuery(this).ajaxSubmit(optionsAuction);
			return false;
		});	
	});
	
	function auction_cp_delete(id){
		jQuery.post(BASE_URI+'admin/dataman/general/auction_coin_delete',{id:id},function(res){
			reload();
		});
	}
	 
	function add_coin_auction(){
		jQuery.post(BASE_URI+'admin/dataman/general/add_coin_auction',{},function(res){
			jQuery('#dialog').html(res);
			jQuery('#dialog').dialog(
				{
					 width: 650,
					 resizable: false,
					 height:200,
					 title: 'Add Auction Coins' 
				}
			);
		});
	}
	function auction_cp_edit(id){
		jQuery.post(BASE_URI+'admin/dataman/general/edit_coin_auction',{id:id},function(res){
			jQuery('#dialog').html(res);
			jQuery('#dialog').dialog(
				{
					 width: 650,
					 resizable: false,
					 height:200,
					 title: 'Edit Auction Coins' 
				}
			);
		});
	}
</script>
